package cn.xiaoliu.hrm.mapper;

import cn.xiaoliu.hrm.domain.LoginUser;
import cn.xiaoliu.hrm.domain.Permission;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author xiaoliu
 * @since 2021-12-16
 */
@Mapper
public interface LoginUserMapper extends BaseMapper<LoginUser> {
    @Select("SELECT\n" +
            "\tt3.* \n" +
            "FROM\n" +
            "\tt_user_role t1\n" +
            "\tLEFT JOIN t_role_permission t2 ON t1.role_id = t2.role_id\n" +
            "\tLEFT JOIN t_permission t3 ON t2.permission_id = t3.id \n" +
            "WHERE\n" +
            "\tt1.user_id = #{id}")
    List<Permission> findPermissions(Long id);
}
